package com.deyuanyun.pic.pbf.controller.dto.validata;

import javax.servlet.http.HttpServletRequest;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.web.RequestResponseContext;
import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import com.deyuanyun.pic.settings.domain.pipe.PipeLine;
import com.deyuanyun.pic.settings.support.utils.PipeDictUtils;

/**
 * 验证管道是否是用户选择的
 * 
 * @author ChenKui
 * @date 2016-02-22
 */
public class PipeLineRequestValidata implements ValidateInterface {

	@Override
	public <T, E,C> boolean apply(T t, E e,C c) {
		if(ObjectUtil.isNotNullEmpty(t)){
			String lineId= PipeDictUtils.getLineIdByName(((String) t).trim());
			if(lineId != null)
			{
			    HttpServletRequest request = RequestResponseContext.getRequest();
				String lineId_request = request.getParameter("pipeLineId");
				
				return lineId.equals(lineId_request);
			}
			return false;
		}
		return false;
	}

	@Override
	public String getName() {
		return null;
	}

}
